package sfeir.gwt.ergosum.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.EventListener;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class GWTErgoSum implements EntryPoint {

    /**
     * This is the entry point method.
     */
    public void onModuleLoad() {
        if (GWT.getModuleName().equals("editprofile")) {
            Element elt = DOM.getElementById("import");
            DOM.setStyleAttribute(elt, "display", "block");
            DOM.setEventListener(elt, new EventListener() {
                @Override
                public void onBrowserEvent(Event event) {
                    
                    if (Event.ONCLICK == event.getTypeInt())
                        new ImportDialog().center();
                }
            });
            DOM.sinkEvents(elt, Event.ONCLICK);
        }
    }

    // redirige le browser sur l'url donnée
    public static native void redirect(String url)/*-{
        $wnd.location = url;
    }-*/;
}
